<?php

//自定义文件，删除缓存文件夹中的文件，解决不同域名下的缓存重复删除的问题

if($_POST["auth"]=="NkeFwxsyQdsgYiBNKIXavV8O8T63uatX"){
        //echo 1;
        deleteContent("../cache/");
}else{
        echo json_encode(["error"=>"no auth message"]);
        exit(0);
}




function deleteContent($path){
      try{
        $iterator = new DirectoryIterator($path);
        foreach ( $iterator as $fileinfo ) {
          if($fileinfo->isDot())continue;
          if($fileinfo->isDir()){
            if(deleteContent($fileinfo->getPathname()))
              @rmdir($fileinfo->getPathname());
          }
          if($fileinfo->isFile()){
            @unlink($fileinfo->getPathname());
          }
        }
      } catch ( Exception $e ){
         // write log
         return false;
      }
      return true;
}

//deleteContent("/www/web/m_hzpayy_cn/wp-content/cache/");

